package com.hk.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author xuebinlu
 * @Date 2018/5/17 13:44
 * @Version 1.0
 * @Description SessionInterceptor 拦截器
 **/
@Component
@Slf4j
public class SessionInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        log.error(request.getRequestURI());
//        if(request.getRequestURI().equals("/userInfo/login")
//                ||request.getRequestURI().equals("/user/login")
//                ||request.getRequestURI().equals("/error")){
//            return true;
//        }
//        Object obj = request.getSession().getAttribute("userNanme");
//        if(obj == null){
//            response.sendRedirect("/user/login");
//            return false;
//        }
        return true;
    }
}
